package com.example.express_order.controller;

import com.example.express_order.domain.Order;
import com.example.express_order.domain.MyResponse;
import com.example.express_order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("order")
public class OrderController {

    @Autowired
    OrderService orderService;

    @RequestMapping("add-order")
    public MyResponse addOrder(String userPhone, String expressDetailAddress,
                               String deliveryAddress, String deliveryMode, String expressType,
                               String estimatedPrice, String userLeisure, String stuffDetail){
        System.out.println(userPhone);
        return orderService.addOrder(userPhone,expressDetailAddress,deliveryAddress,deliveryMode,expressType,
                 estimatedPrice, userLeisure, stuffDetail);
    }


    /**
     * 接单，修改订单状态
     */
    @RequestMapping("accept-order-by-orderID-and-courier-phone")
    public MyResponse acceptOrderByOrderIDAndCourierPhone(String courierPhone, String orderId){
        return orderService.acceptOrderByOrderIDAndCourierPhone(courierPhone,orderId);
    }
    /**
     * 客户订单完成
     */
    @RequestMapping("customer-confirm-order")
    public MyResponse customerConfirmOrder(String orderId){

        return orderService.customerConfirmOrder(orderId);
    }
    /**
     * 普通用户查看历史订单
     */
    @RequestMapping("find-history-common-user-order-by-phone")
    public List<Order> findHistoryCommonUserOrderByPhone(String userPhone){
        return orderService.findHistoryCommonUserOrderByPhone(userPhone);
    }


    /**
     * 快递员配送查看历史订单
     */
    @RequestMapping("find-history-delivery-order-by-courier-phone")
    public List<Order> findHistoryDeliveryOrderByCourierPhone(String courierPhone){
        return orderService.findHistoryDeliveryOrderByCourierPhone(courierPhone);
    }

    @RequestMapping("find-my-post-order")
    public List<Order> findMyPostOrder(String userPhone){
        return orderService.findMyPostOrder(userPhone);
    }
    @RequestMapping("find-wait-finish-orders")
    public List<Order> findWaitFinishOrders(String userPhone){
        return orderService.findWaitFinishOrders(userPhone);
    }
    @RequestMapping("find-my-receive-orders")
    public List<Order> findMyReceiveOrders(String courierPhone){
        return orderService.findMyReceiveOrders(courierPhone);
    }


}
